$i=600851475143;

for ($j=2;$j<=$i;$j++) {
    while ($i%$j==0) {
        $i/=$j;
        $factor=$j;
    }
}

print "$factor\n";